home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / fielddh.exe / MSGBOX.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-30  |  18KB  |  465 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Turbo Pascal Version 6.0                        }
  4. {       Turbo Vision Unit                               }
  5. {                                                       }
  6. {       Copyright (c) 1990 Borland International        }
  7. {                                                       }
  8. {*******************************************************}
  9. {  Doug Hood, CIS 70324,3336                            }
  10. {    Released to the PUBLIC DOMAIN                      }
  11. {*******************************************************}
  12. {     MODS: added Multiple line capability              }
  13. {           added NoEcho input box                      }
  14. {           added Date  input box                       }
  15. {           added Button_Order_Flag                     }
  16. {            (lists buttons backwards order)            }
  17. {                                                       }
  18. {*******************************************************}
  19.  
  20. unit MsgBox;
  21.  
  22. {$F+,O+,X+,D-}
  23.  
  24. interface
  25.  
  26. uses Objects;
  27.  
  28. const
  29.  
  30. { Message box classes }
  31.  
  32.   mfWarning      = $0000;       { Display a Warning box }
  33.   mfError        = $0001;       { Dispaly a Error box }
  34.   mfInformation  = $0002;       { Display an Information Box }
  35.   mfConfirmation = $0003;       { Display a Confirmation Box }
  36.  
  37. { Message box button flags }
  38.  
  39.   mfYesButton    = $0100;       { Put a Yes button into the dialog }
  40.   mfNoButton     = $0200;       { Put a No button into the dialog }
  41.   mfOKButton     = $0400;       { Put an OK button into the dialog }
  42.   mfCancelButton = $0800;       { Put a Cancel button into the dialog }
  43.  
  44.   mfYesNoCancel  = mfYesButton + mfNoButton + mfCancelButton;
  45.                                 { Standard Yes, No, Cancel dialog }
  46.   mfOKCancel     = mfOKButton + mfCancelButton;
  47.                                 { Standard OK, Cancel dialog }
  48.  
  49. {-*************************************************************-}
  50. { MessageBox displays the given string in a standard sized      }
  51. { dialog box. Before the dialog is displayed the Msg and Params }
  52. { are passed to FormatStr.  The resulting string is displayed   }
  53. { as a TStaticText view in the dialog.                          }
  54. {     (use 'hello'#13'there' to split a string into 2 lines)    }
  55. {-*************************************************************-}
  56.  
  57. function MessageBox(Msg: String; Params: Pointer; AOptions: Word): Word;
  58. function MessageBox2(Msg1: String; Params1: Pointer;
  59.                      Msg2: String; Params2: Pointer;
  60.                      Msg3: String; Params3: Pointer;
  61.                      Msg4: String; Params4: Pointer;
  62.                      AOptions: Word;
  63.                      Button_Order_Normal : boolean): Word;
  64. function Simple_Message (Msg : string) : Word;
  65.  
  66.  
  67. {-*************************************************************-}
  68. { MessageBoxRec allows the specification of a TRect for the     }
  69. { message box to occupy.                                        }
  70. {-*************************************************************-}
  71.  
  72. function MessageBoxRect  (var R: TRect; Msg: String; Params: Pointer;
  73.                           AOptions: Word): Word;
  74. function MessageBoxRect2 (var R: TRect; Msg1: String; Params1: Pointer;
  75.                           Msg2: String; Params2: Pointer;
  76.                           Msg3: String; Params3: Pointer;
  77.                           Msg4: String; Params4: Pointer;
  78.                           AOptions: Word;
  79.                           Button_Order_Normal : boolean): Word;
  80.  
  81.  
  82. {-*************************************************************-}
  83. { InputBox displays a simple dialog that allows the user to     }
  84. { type in a string.                                             }
  85. {-*************************************************************-}
  86.  
  87. function InputBox(Title: String; ALabel: String; var S: String;
  88.   Limit: Byte): Word;
  89.  
  90.  
  91. {-*************************************************************-}
  92. { InputBoxRect is like InputBox but allows the specification of }
  93. { a rectangle.                                                  }
  94. {-*************************************************************-}
  95.  
  96. function InputBoxRect(var Bounds: TRect; Title: String; ALabel: String;
  97.   var S: String;  Limit: Byte): Word;
  98.  
  99.  
  100. {-*************************************************************-}
  101. { NoEcho_InputBox displays a simple dialog that allows the user }
  102. { to type in a string, but only '*'s are echoed to the screen.  }
  103. {-*************************************************************-}
  104. function NoEcho_InputBox (Title: String; ALabel: String; var S: String;
  105.                           Limit: Byte;
  106.                           Force_Uppercase : boolean): Word;
  107.  
  108.  
  109. {-*************************************************************-}
  110. { NoEcho_InputBoxRect is like NoEcho_InputBox but allows the    }
  111. { specification of  a rectangle.                                }
  112. {-*************************************************************-}
  113. function NoEcho_InputBoxRect (var Bounds      : TRect;
  114.                               Title, ALabel   : string;
  115.                               var S           : string;
  116.                               Limit           : byte;
  117.                               Force_Uppercase : boolean) : word;
  118.  
  119. {-*************************************************************-}
  120. { Date_InputBox displays a simple dialog that allows the user   }
  121. { to type in a string, checks for valid date                 .  }
  122. {-*************************************************************-}
  123. function Date_InputBox  (Title: String; ALabel: String; var S: String;
  124.                          Limit: Byte;
  125.                          Default_Today   : boolean;
  126.                          Var Day,Month, Year : word) : word;
  127. {-*************************************************************-}
  128. { Date_InputBoxRect is like Date_InputBox but allows the        }
  129. { specification of  a rectangle.                                }
  130. {-*************************************************************-}
  131. function Date_InputBoxRect (var Bounds      : TRect;
  132.                             Title, ALabel   : string;
  133.                             var S           : string;
  134.                             Limit           : byte;
  135.                             Default_Today   : boolean;
  136.                             Var Day,Month, Year : word) : word;
  137.  
  138. {************************************************************************}
  139. {************************************************************************}
  140. {************************************************************************}
  141. IMPLEMENTATION
  142.  
  143. uses Drivers, Views, Dialogs, App,
  144.      Fields_Color;  {for noecho_inputline, date_inputline}
  145.  
  146. {*************************************************************************}
  147. function Simple_Message (Msg : string) : Word;
  148. begin
  149.   Simple_Message := MessageBox2 (Msg, nil, '',nil, '',nil, '',nil,
  150.                                  mfInformation+mfOkButton, TRUE);
  151. end; {simple_message}
  152.  
  153. {*************************************************************************}
  154. function MessageBox (Msg: String; Params: Pointer;
  155.                      AOptions: Word): Word;
  156. begin
  157.   MessageBox := MessageBox2 (Msg, Params, '',nil, '',nil, '',nil,
  158.                              AOptions, TRUE);
  159. end; {messagebox}
  160.  
  161. {*************************************************************************}
  162. function MessageBox2(Msg1: String; Params1: Pointer;
  163.                      Msg2: String; Params2: Pointer;
  164.                      Msg3: String; Params3: Pointer;
  165.                      Msg4: String; Params4: Pointer;
  166.                      AOptions: Word;
  167.                      Button_Order_Normal : boolean): Word;
  168. var
  169.   R: TRect;
  170. begin
  171.   R.Assign(0, 0, 40, 9);
  172.   R.Move((Desktop^.Size.X - R.B.X) div 2, (Desktop^.Size.Y - R.B.Y) div 2);
  173.   MessageBox2 := MessageBoxRect2 (R, Msg1, Params1,
  174.                                   Msg2, Params2,
  175.                                   Msg3, Params3,
  176.                                   Msg4, Params4,
  177.